package com.kaifamiao.N0808;

public class Node2 {

    public static int maxSubString1(String str) {
        if (str == null && str.isEmpty()) {
            return -1;
        }

        if (str.length() == 1) {
            return 1;
        }
        int max = 0;

        for (int i = 0; i < str.length(); i++) {
            StringBuilder sb = new StringBuilder(String.valueOf(str.charAt(i)));
            for (int j = i + 1; j < str.length(); j++) {
                String current = String.valueOf(str.charAt(i));
                int index = sb.indexOf(current);
                if (index >= 0) {
                    if (sb.length() > max) {
                        max = sb.length();
                    }
                    break;
                } else {
                    sb.append(current);
                }
            }
            if (sb.length() > max) {
                max = sb.length();
            }
        }

        return max;
    }

    public static void main(String[] args) {
        String str = "pwabwkew";
        int length = maxSubString1(str);
        System.out.println(length);
    }
}